package com.java.test5;

/**
 * @author luzhikun
 * @date 2020/12/20-21:20
 */
public class EcmDef {
    public static void main(String[] args) {
        try {
            System.out.println("我是一号");
            int i = Integer.parseInt(args[0]);
            System.out.println("我是二号");
            int j = Integer.parseInt(args[1]);
            int result = ecm(i, j);
            System.out.println(result);
            System.out.println("吴杰是头猪");
        } catch (EcDef e) {
            System.out.println(e.getMessage());
        } catch (NumberFormatException e) {
            e.printStackTrace();
            System.out.println("数据类型不一致");
        } catch (ArrayIndexOutOfBoundsException e) {
            e.printStackTrace();
            System.out.println("命令行缺少参数");
        } catch (ArithmeticException e) {
            e.printStackTrace();
            System.out.println("输入负数了");
        }

        System.out.println("吴杰是猪");

    }

    public static int ecm(int i, int j) throws EcDef {
        if (i < 0 || j < 0) {
            throw new EcDef("不能为负数");
        } else
            return i / j;
    }
}
